<?php echo form_open('commandes');?>
<div class="divrondform">
	<div style="margin-left:50px; margin-top:20px;">
		<table>
			<tr>
				<td>
					<table id="commandes_grid" style="cursor:pointer"></table>
				</td>
				<td valign="top" width="300px" style="margin:auto;">
					<?php if($this->session->userdata['admin'] == "O") { ?>
					    <input class="boutons" name="BCommandes" type="submit" value="Cr&eacute;er commande group&eacute;e" style="width:220 px" <?php if($en_prep > 0) { echo 'disabled="disabled"'; }?>/><br><br>
					<?php } ?>
					<input class="boutons" name="BCommandes" id="BC" type="submit" value="Entrer ma commande" style="width:220 px" <?php if($en_prep == 0) { echo 'disabled="disabled"'; }?> /><br><br>
					<input class="boutons" name="BCommandes" id="BCV" type="submit" value="Voir ma commande" style="width:220 px" /><br><br>
					<?php if($this->session->userdata['admin'] == "O") { ?>
						<input class="boutons" name="BCommandes" id="BCG" type="submit" value="G&eacute;rer commande" style="width:220 px" /><br><br>
					<?php } ?>
					<input class="boutons" name="BCommandes" type="submit" value="D&eacute;connexion" style="width:130 px" /><br><br>
					<input type="hidden" name="NCommande" id="NCommande" value="NULL"/>
					<input class="boutons" valign="bottom" name="BCommandes" type="button" value="Promo en cours" style="width:130 px" onclick="AfficherPromo()"/><br><br>
				</td>	
			</tr>
		</table>
	</div>
	<div id="pager"></div>
	<?php echo $commandesGrille; ?>
	<br>
</div>    
</form>

<input id="pub_date_debut" type="hidden" value="<?php echo $pub_date_debut; ?>" />
<input id="pub_date_fin" type="hidden" value="<?php echo $pub_date_fin; ?>" />
<input id="pub_pdf"  type="hidden" value="<?php echo $pub_pdf; ?>" />
<input id="pub_largeur"  type="hidden" value="<?php echo $pub_largeur; ?>" />
<input id="pub_hauteur"  type="hidden" value="<?php echo $pub_hauteur; ?>" />
<input id="fromlogin" type="hidden" value="<?php echo $fromlogin; ?>" />

<div id="divpdf"><a class="fancybox-pdf" href="<?php echo $pub_pdf; ?>"></a></div>

<script>

function dblClick(id) {
	$("#NCommande").val(id);
	$("#BC").click();
}
function selectRow(id) {
    $("#NCommande").val(id);	
}

function AfficherPromo() {
	// Gestion du PDF de publicité
	// Récupération des valeurs 
	var fromlogin      = $('#fromlogin').val();
	var pub_date_debut = $('#pub_date_debut').val();
	var pub_date_fin   = $('#pub_date_fin').val();
	var pub_largeur    = $('#pub_largeur').val();
	
	var pub_hauteur    = $('#pub_hauteur').val();
	// Calcul des dates
	var date_debut = new Date(pub_date_debut.substring(6,10)+"-"+ pub_date_debut.substring(3,5)+"-"+pub_date_debut.substring(0,2));
	var date_fin   = new Date(pub_date_fin.substring(6,10)+"-"+ pub_date_fin.substring(3,5)+"-"+pub_date_fin.substring(0,2));
	var date_jour  = new Date(); // Aujourd'hui
	
	if(date_jour.getTime() >= date_debut.getTime() &&  date_jour.getTime() <= date_fin.getTime() && fromlogin == 'VRAI') {
		// for PDF auto-detection 
		$('a[href$=".pdf"]').addClass('fancybox-pdf'); 
		// setup FB for PDF using type iframe 
		$('a.fancybox-pdf').fancybox({ 
	    		'type'         		 	:'iframe', 
	        	'titleShow'    			: false, 
	       		'autoScale'     		: false,
	       		'padding'				: 0,
	      	  	'width'         		: parseInt(pub_largeur), 
	        	'height'                : parseInt(pub_hauteur)
		}); 

		$("a.fancybox-pdf").trigger('click');
	}
	
}

$(document).ready(function() {
	AfficherPromo();
	setTimeout(function() {	parent.$.fancybox.close(); }, 8000 );
});

</script>
	

